Skip to content

fix: 7 correctness bugs from adversarial review of this session's code (deja floor, harden worktree, ledger-sync, cortex metric, verify base, radar usage, precommit parse)#70

Merged
CodeWithJuber merged 1 commit into
masterfrom
claude/research-paper-implementation-va5g2u
Jul 17, 2026
Merged

fix: 7 correctness bugs from adversarial review of this session's code (deja floor, harden worktree, ledger-sync, cortex metric, verify base, radar usage, precommit parse)#70
CodeWithJuber merged 1 commit into
masterfrom
claude/research-paper-implementation-va5g2u

Conversation

@CodeWithJuber

Copy link
Copy Markdown
Owner

What & why

An adversarial audit (13 module reviewers → per-finding refutation by an independent skeptic) of everything shipped this session (v0.19→v0.21) confirmed 7 real, reachable bugs and rejected the rest. This PR fixes all seven, each with a verified failure scenario. One is a high-severity silent feature failure.

Severity File Bug → fix
HIGH src/deja.js DEJA_FLOOR (0.55) exceeded the ~0.42 max retrieve() can score for a repo-scoped summary (σ term < 0.73 × 0.6 scope-weight), so the déjà-vu advisory could never fire — the whole anti-repetition feature was a silent no-op. Recalibrated to 0.39 (band: unrelated ≈0.34, identical ≈0.42) + an end-to-end regression test (recordSessionSummarydejaAdvisory) so it can't drift out of range again.
MEDIUM src/harden.js In a linked worktree/submodule .git is a file, so mkdirSync('.git/hooks') threw ENOTDIR and aborted forge harden. Hooks dir now resolved via git rev-parse --git-path hooks.
MEDIUM src/ledger_sync.js The up-to-date short-circuit compared against a stale local refs/<cli>/ledger from a prior remote, so a new/pruned remote was reported upToDate without ever being pushed to. Now only trusts it when the fetch actually found the ref on this remote.
MEDIUM src/cortex_hook_main.js Preflight halt metric read result.gate?.halted — a field substrateCheck() never returns — so the cost dashboard's halt-rate was permanently zero. Now reads assumption.shouldAsk.
LOW src/verify.js added fell back to --cached but changedFiles didn't, so verify --deep's structural lenses went silent on a base whose worktree matches HEAD while the index differs. changedFiles now mirrors the fallback.
LOW src/radar.js lodash could steal lodash.debounce's import count via a first-match break in alphabetical order. Names are now matched most-specific-first.
LOW src/commit_gate.js An added line beginning with ++ rendered as +++ and was misread as a diff header. The parser now tracks hunk state so headers only match before @@.

Checklist

  • npm test passes — 887 pass / 0 fail / 2 skip
  • npm run check passes (Biome — 6 pre-existing warnings, 0 errors)
  • New public functions have a test (deja advisory end-to-end regression test added)
  • Conventional commit message
  • CHANGELOG.md updated under ## [Unreleased] (### Fixed, 7 bullets)
  • No new runtime dependency
  • Substrate/docs updated — no command surface change; docs check green

Risk & rollback

  • Risk level: low — all seven are localized correctness fixes; behavior only changes in the buggy paths. The deja floor change is calibrated against measured score ranges with a regression test; the harden/ledger-sync fixes add fallbacks without changing the happy path.
  • Rollback plan: revert the single commit. No schema or API change.

Extra checks (tick if applicable)

  • npm run typecheck passes
  • Input validated at boundaries; errors handled — every fix preserves the module's fail-open/fail-safe contract
  • Authorization/ownership checked (n/a)
  • Logs contain no secrets/PII
  • If AI-assisted: findings independently verified (each survived an adversarial refutation pass), fixes have tests

🤖 Generated with Claude Code

https://claude.ai/code/session_017Ebv4QDTqzPzgApBW2KUsU


Generated by Claude Code

…19–v0.21 code

An adversarial review (13 reviewers → per-finding refutation) of everything shipped
this session confirmed 7 real, reachable bugs and rejected the rest. Fixes:

- deja: DEJA_FLOOR 0.55 → 0.39 — the old floor exceeded the ~0.42 score() ceiling for a
  repo-scoped summary, so the déjà-vu advisory could NEVER fire (HIGH; core feature was a
  silent no-op). Adds an end-to-end recordSessionSummary→dejaAdvisory regression test.
- harden: resolve the git hooks dir via `git rev-parse --git-path hooks` — .git is a FILE
  in a linked worktree/submodule, so the hardcoded .git/hooks threw ENOTDIR (MEDIUM).
- ledger_sync: only trust the up-to-date short-circuit when the fetch found the ref on THIS
  remote — a shared ref name left over from another remote could skip the push (MEDIUM).
- cortex_hook_main: preflight halt metric read a non-existent result.gate?.halted → always
  "pass"; now reads assumption.shouldAsk (MEDIUM).
- verify: changedFiles now mirrors added's --cached fallback so the structural lenses don't
  go silent on a mismatched evidence base (LOW).
- radar: match dep names most-specific-first so lodash.debounce isn't swallowed by lodash's
  member prefix (LOW).
- commit_gate: track hunk state so an added line beginning with `++ ` isn't misread as a
  `+++ ` diff header (LOW).

Full suite 887 pass / 0 fail / 2 skip; biome/tsc/docs check green.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017Ebv4QDTqzPzgApBW2KUsU
@CodeWithJuber
CodeWithJuber marked this pull request as ready for review July 17, 2026 17:09
@CodeWithJuber
CodeWithJuber merged commit c495734 into master Jul 17, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants